package com.bjpowernode.service.impl;

import com.bjpowernode.dao.FollowDao;
import com.bjpowernode.service.FollowService;
import com.bjpowernode.user.Follow;
import com.bjpowernode.user.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class FollowServiceImpl implements FollowService {

    @Resource
    private FollowDao followDao;

    @Override
    public int addFollow(Follow follow) {
        Follow resFollow = followDao.selectFollow(follow);
        return resFollow == null ? followDao.insertFollow(follow) : 0;
    }

    @Override
    public int removeFollow(Follow follow) {
        return followDao.deleteFollow(follow);
    }

    @Override
    public List<User> findSelfFollow(String name) {
        return followDao.selectSelfFollow(name);
    }

    @Override
    public Integer findFollowSum(String name) {
        return followDao.selectFollowSum(name).size();
    }

    @Override
    public Integer findFansSum(String name) {
        return followDao.selectFansSum(name).size();
    }
}
